Open
Conversation
xrmx
approved these changes
Apr 14, 2026
xrmx
reviewed
Apr 14, 2026
80a4f86 to
284dece
Compare
xrmx
reviewed
Apr 15, 2026
herin049
approved these changes
Apr 16, 2026
herin049
reviewed
Apr 16, 2026
Comment on lines
+51
to
+65
| raw: list[dict] = [] | ||
|
|
||
| def collect(obj: Any) -> None: | ||
| if isinstance(obj, dict): | ||
| if "live_check_result" in obj: | ||
| for advice in obj["live_check_result"].get("all_advice", []): | ||
| if advice.get("level") == "violation": | ||
| raw.append(advice) | ||
| for val in obj.values(): | ||
| collect(val) | ||
| elif isinstance(obj, list): | ||
| for item in obj: | ||
| collect(item) | ||
|
|
||
| collect(report) |
Contributor
There was a problem hiding this comment.
Now that we've dropped 3.9, you could do:
def _collect(obj: Any) -> list[dict]:
match obj:
case {"live_check_result": {"all_advice": advices}, **_rest}:
violations = [a for a in advices if a.get("level") == "violation"]
return violations + list(chain.from_iterable(_collect(v) for v in obj.values()))
case dict():
return list(chain.from_iterable(_collect(v) for v in obj.values()))
case list():
return list(chain.from_iterable(_collect(item) for item in obj))
case _:
return []
raw = _collect(report)
Member
Author
There was a problem hiding this comment.
it segfaults on pypy 310 on ubuntu, reverted some parts
Fatal Python error: Segmentation fault
Stack (most recent call first, approximate line numbers):
File "/home/runner/work/opentelemetry-python/opentelemetry-python/tests/opentelemetry-test-utils/src/opentelemetry/test/weaver_live_check.py", line 54 in _collect
File "/home/runner/work/opentelemetry-python/opentelemetry-python/tests/opentelemetry-test-utils/src/opentelemetry/test/weaver_live_check.py", line 65 in <genexpr>
File "/home/runner/work/opentelemetry-python/opentelemetry-python/tests/opentelemetry-test-utils/src/opentelemetry/test/weaver_live_check.py", line 54 in _collect
File "/home/runner/work/opentelemetry-python/opentelemetry-python/tests/opentelemetry-test-utils/src/opentelemetry/test/weaver_live_check.py", line 69 in <genexpr>
File "/home/runner/work/opentelemetry-python/opentelemetry-python/tests/opentelemetry-test-utils/src/opentelemetry/test/weaver_live_check.py", line 54 in _collect
File "/home/runner/work/opentelemetry-python/opentelemetry-python/tests/opentelemetry-test-utils/src/opentelemetry/test/weaver_live_check.py", line 65 in <genexpr>
File "/home/runner/work/opentelemetry-python/opentelemetry-python/tests/opentelemetry-test-utils/src/opentelemetry/test/weaver_live_check.py", line 54 in _collect
File "/home/runner/work/opentelemetry-python/opentelemetry-python/tests/opentelemetry-test-utils/src/opentelemetry/test/weaver_live_check.py", line 41 in _extract_violations
File "/home/runner/work/opentelemetry-python/opentelemetry-python/tests/opentelemetry-test-utils/src/opentelemetry/test/weaver_live_check.py", line 175 in violations
File "/opt/hostedtoolcache/PyPy/3.10.16/x64/lib/pypy3.10/functools.py", line 973 in __get__
File "/home/runner/work/opentelemetry-python/opentelemetry-python/tests/opentelemetry-test-utils/tests/test_weaver_live_check.py", line 64 in test_end_and_check_no_violations
lmolkova
commented
Apr 17, 2026
| -e tests/opentelemetry-test-utils | ||
| # these are required for weaver integration tests, we're running that only on linux | ||
| # because of lack of support for gRPC on Windows in some cases. | ||
| # note: tox does not support PEP 508 markers on `-e` editable installs, so these are installed non-editable |
Member
Author
There was a problem hiding this comment.
for whatever reason tox does not like -e along with platform marker, but we don't really need those as editable
39b4fcf to
270c9d2
Compare
1094e5b to
00d6e47
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds
WeaverLiveCheckhelper that allows to validate instrumentation output against otel semconv.Examples:
report = check.end()and it won't raise. You can explore report (which contains a list of violations and also full weaver report as dict from json) - party onreport = check.end_and_check()and it'd raiseLiveCheckError(extendsAssertionError) if any violations are found. You still get full report as a property on the error if you want to assert on moreChecklist: